#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "aboutdialog.h"
#include <QFileDialog>
#include <QBoxLayout>
#include <QLabel>
#include <QDebug>
#include <QImage>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_quitButton_clicked()
{
    qApp->quit();
}


void MainWindow::on_quitFromMenu_triggered()
{
    qApp->quit();
}

void MainWindow::on_actionOpen_triggered()
{
    QImage myImage;
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),"",tr("Images (*.jpg)"));
    bool result = myImage.load(fileName);
    if(result)
        qDebug() << "Image Loaded";

    QLabel myLabel;
    myLabel.setPixmap(QPixmap::fromImage(myImage));
    myLabel.setParent(this);
    myLabel.show();
}

void MainWindow::on_actionOpen_Presentation_triggered()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open Presentation"),"", tr("Presentation File (*.prs)"));
}

void MainWindow::on_actionAdd_To_Presentation_triggered()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),"",tr("Images (*.jpg)"));
}

void MainWindow::on_actionAbout_triggered()
{
//    QDialog aboutBox;
//    aboutBox.setFixedSize(QSize(610,300));
//    aboutBox.setWindowIcon(QPixmap(":/graphics/logo_temp.png"));
//    aboutBox.setWindowTitle("About PhotoDesk");
//    QLabel logo;
//    logo.setPixmap(QPixmap(":/graphics/logo_temp.png"));
//    QLabel aboutText;
//    aboutText.setWordWrap(true);
//    aboutText.setText("<h3><b>PhotoDesk 1.0 Alpha</b></h3><p style='color:blue'>Developers: Christine Pan & Edward Arteaga</p><p>Thank you for using PhotoDesk!</p>");
//    QBoxLayout aboutBoxLayout(QBoxLayout::LeftToRight, this);
//    aboutBoxLayout.addWidget(&logo);
//    aboutBoxLayout.addWidget(&aboutText);
//    aboutBox.setLayout(&aboutBoxLayout);
//    aboutBox.exec();
    AboutDialog aboutD;
    aboutD.show();
    aboutD.exec();
}

void MainWindow::on_actionFull_Screen_toggled(bool arg1)
{
    if (this->isFullScreen()){
        this->showMaximized();
    }
    else{
        this->showFullScreen();
    }

}

void MainWindow::printSize(){
    qDebug() << "minSize: " << ui->dockWidget->minimumSize() << endl;
    qDebug() << "maxSize: " << ui->dockWidget->maximumSize() << endl;
    qDebug() << "sizeHint:" << ui->dockWidget->sizeHint() << endl;
}


